#include <bits/stdc++.h>
using namespace std;

void func(queue<char>& q,stack<char>& ret,vector<char>& tmp,char x)
{
	q.push(x);
    while(!ret.empty())
    {
      char r=ret.top();
      ret.pop();
      q.push(r);
      tmp.pop_back();
      if(r==x) break;
    }
}

int main()
{
  queue<char> qa;
  queue<char> qb;
  stack<char> ret;
  vector<char> tmp;
  string input;
    getline(cin, input);
    for (char c : input) 
        qa.push(c);
    getline(cin, input);
    for (char c : input)
        qb.push(c);
    int i=1000000;
    bool cab=true;//true=a,false=b
  while(!qa.empty()&&!qb.empty()&&i--)
  {
    if(cab)
    {
      char a=qa.front();
      qa.pop();
      if(find(tmp.begin(),tmp.end(),a)!=tmp.end())
      {
        func(qa,ret,tmp,a);
      }
      else
      {
        tmp.push_back(a);
        ret.push(a);
        cab=false;
      }
    }
    if(!cab)
    {
      char b=qb.front();
      qb.pop();
      if(find(tmp.begin(),tmp.end(),b)!=tmp.end())
        func(qb,ret,tmp,b);
      else
      {
        tmp.push_back(b);
        ret.push(b);
        cab=true;
      }
    }
  }
  if(!qa.empty()&&!qb.empty())
  {
    cout<<-1;
  }
  else if(!qa.empty())
  {
    while(qa.size())
    {
   	  cout<<qa.front();
   	  qa.pop();
    }
  }
  else if(!qb.empty())
  {
    while(qb.size())
	  {
		  cout<<qb.front();
		  qb.pop();
	  }
  }
  return 0;
}//Q24QAXA3A34K5845689XJ5
